package com.example.edu.Controller;

import com.example.edu.Dto.*;
import com.example.edu.Entity.Article;
import com.example.edu.Service.DraftService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/admin/draft")
public class DraftController {
    @Resource
    private DraftService draftService;

    @PostMapping("/create")
    public Result create(@RequestHeader("Authorization") String token, @RequestBody CreateArticleDto createDraftDto){
        return draftService.create(token,createDraftDto);
    }

    @PostMapping("/delete")
    public Result delete(@RequestHeader("Authorization") String token, @RequestBody Article article_id){
        return draftService.delete(token,article_id);
    }

    @PostMapping("/update")
    public Result update(@RequestHeader("Authorization") String token, @RequestBody UpdateArticleDto updateDraftDto){
        return draftService.update(token,updateDraftDto);
    }

    @PostMapping("/getList")
    public Result getList(@RequestHeader("Authorization") String token, @RequestBody PageDto pageDto){
        return draftService.getList(token,pageDto);
    }

    @PostMapping("/search")
    public Result search(@RequestHeader("Authorization") String token, @RequestBody SearchDto searchDto){
        return draftService.search(token,searchDto);
    }

    @PostMapping("/get")
    public Result get(@RequestBody Article article_id){
        return draftService.get(article_id);
    }

    @PostMapping("/publish")
    public Result publish(@RequestBody Article article_id){
        return draftService.publish(article_id);
    }

    @PostMapping("/save")
    public Result save(@RequestHeader("Authorization") String token, @RequestBody SaveDto saveDto){
        return draftService.save(token,saveDto);
    }
}
